//
//  BLHotelDetailViewController.m
//  blanket
//
//  Created by Mac on 2018/11/14.
//  Copyright © 2018 stoneobs@icloud.com. All rights reserved.
//

#import "BLRoomDetailViewController.h"
#import "BLHotelDetailModel.h"
#import "BLDatePresentViewController.h"
#import "BLHotelCommitViewController.h"
@interface BLRoomDetailViewController ()
@property(nonatomic, strong) STAdvertingScrollView                     *adverView;/**< <##> */
@property(nonatomic, strong) STLabel                        *titleLable;
@property(nonatomic, strong) STLabel                         *priceLable;//积分商城隐藏，采集商城展示
@property(nonatomic, strong) STLabel                         *desLable;
@end

@implementation BLRoomDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"铺盖酒店";
    [self configSubView];
    // Do any additional setup after loading the view.
}

#pragma mark --subView
- (void)configSubView{
    
    UIView * header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 100)];
    header.backgroundColor = [UIColor whiteColor];
    
    self.adverView = [[STAdvertingScrollView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 275) andWithArray:@[@"banner1",@"banner1",@"banner1",@"banner1",@"banner1"] handle:^(NSInteger num) {
        
    }];
    self.adverView.pageControll.bottom = self.adverView.height - 15;
    self.adverView.pageControll.currentPageIndicatorTintColor = [UIColor whiteColor];
    self.adverView.pageControll.pageIndicatorTintColor = KL_BlueBackGroundColor;
    self.adverView.pageControll.centerX = UIScreenWidth / 2;
    self.adverView.canAutoScroll = YES;
    self.adverView.time = 5;
    [header addSubview:self.adverView];
    self.adverView.imageUrlsArray = @[self.model.img];
    
    self.titleLable = [[STLabel alloc] initWithFrame:CGRectMake(10, self.adverView.bottom +10, UIScreenWidth - 20, 40)
                                                text:self.model.room_name
                                           textColor:BL_secendTextColor
                                                font:14
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentLeft];
    self.titleLable.numberOfLines = 0;
    [header addSubview:self.titleLable];
    
    self.priceLable = [[STLabel alloc] initWithFrame:CGRectMake(0 + 10, self.titleLable.bottom, UIScreenWidth - 20 , 20)
                                                text:@"价格:￥456"
                                           textColor:BL_redColor
                                                font:14
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentLeft];
    [header  addSubview:self.priceLable];
    self.priceLable.text = [NSString stringWithFormat:@"价格:￥%@",_model.price];
    self.priceLable.attributedText = [self.priceLable.text st_convertAttributeStringWithKeyWord:@"价格:" attributes:@{NSForegroundColorAttributeName:BL_secendTextColor}];
    
    
    self.desLable = [[STLabel alloc] initWithFrame:CGRectMake( 10, self.priceLable.bottom + 10, UIScreenWidth - 20 - 0, 20)
                                              text:[NSString stringWithFormat:@"酒店简介:%@",self.model.brief]
                                         textColor:BL_secendTextColor
                                              font:14
                                       isSizetoFit:NO
                                     textAlignment:NSTextAlignmentLeft];
    [header addSubview:self.desLable];
    [NSString lableAutoAdjustheightWithLabel:self.desLable];
    
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(10, self.desLable.bottom, UIScreenWidth - 20, 20)
                                                     text:[NSString stringWithFormat:@"酒店电话:%@",
                                                           self.detailModel.phone]
                                                textColor:BL_secendTextColor
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    [header addSubview:titleLable];
    
    [NSString lableAutoAdjustheightWithLabel:titleLable];
    
    UIView * line = [[UIView alloc] initWithFrame:CGRectMake(0, titleLable.bottom + 35, UIScreenWidth, 0.5)];
    line.backgroundColor = BL_lineColor;
    [header addSubview:line];
    
    UIView * titileView = [TMUtils headerViewWithTitle:@"商品详情"];
    titileView.top = line.bottom  +10;
    [header addSubview:titileView];
    
    //配置图片
    CGFloat top = titileView.bottom;
    header.height = top + 10;
    self.tableView.tableHeaderView = header;
    
    self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 49)];
    
    STButton * priceButton = [[STButton alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth / 2, 49)
                                                       title:[NSString stringWithFormat:@"￥%@",self.model.price]
                                                  titleColor:UIColor.redColor
                                                   titleFont:15
                                                cornerRadius:0
                                             backgroundColor:UIColor.whiteColor
                                             backgroundImage:nil
                                                       image:nil];
    priceButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    priceButton.top = TMUtils.tabbar.top;
    [self.view addSubview:priceButton];
    
    __weak typeof(self) weakSelf =  self;
    STButton * buyButton = [[STButton alloc] initWithFrame:CGRectMake( UIScreenWidth / 2, 0, UIScreenWidth / 2, 49)
                                                     title:@"预定"
                                                titleColor:UIColor.whiteColor
                                                 titleFont:15
                                              cornerRadius:0
                                           backgroundColor:BL_BlueBackGroundColor
                                           backgroundImage:nil
                                                     image:nil];
    buyButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    buyButton.top = TMUtils.tabbar.top;
    [buyButton setClicAction:^(UIButton *sender) {
        BLDatePresentViewController * vc = BLDatePresentViewController.new;
        [vc setDidChosedTime:^(NSArray<NSDate *> *chosedDates) {
            weakSelf.model.dateArray = chosedDates;
            BLHotelCommitViewController * commitvc = BLHotelCommitViewController.new;
            commitvc.detailModel  = weakSelf.model;
            commitvc.hotelModel = self.detailModel;
            [weakSelf.navigationController pushViewController:commitvc animated:YES];
        }];
        [weakSelf presentViewController:vc animated:NO completion:nil];
    }];
    [self.view addSubview:buyButton];
    
}
#pragma mark --NetWork Method

@end
